#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int ispalindromo(char *string);

int main(){

	FILE *arq;

	arq = fopen("arquivo.txt","r");

	if(arq == NULL)
		printf("Falha ao abrir o arquivo");
	else{
		char *word;
		int i;
		
		
		word = malloc(10*sizeof(char));
		
		/*fscanf (arq, "%s", word);
		printf("A palavra lida é %s\n", word);
		
		if(ispalindromo(word)){				
			printf("+\n");
		}else{
			printf("-\n");
		}*/
		while(!feof(arq)){
			fscanf (arq, "%s", word);
			printf("A palavra lida é %s\n", word);
			if(ispalindromo(word)){				
				printf("+\n");
			}else{
				printf("-\n");
			}

		}
	}
	fclose(arq);

	return 0;
}

int ispalindromo(char *string){

	
	int i=0;
	int tam = strlen(string);
	int res;
	
	if( tam%2 == 0 ){

		for(i = 0 ; i < tam/2 ; i++){
			//printf("i= %d --- %c  tam-i= %d --- %c\n",i,string[i],tam-i,string[tam-1-i]);
			if(string[i] != string[tam-1-i])
				return 0;

		}
	return 1;
	}
	else{
		while( i != tam/2){
			if(string[i] != string[tam-1-i])
				return 0;
			i++;
		}
	
	return 1;
	}
}
